package com.xyh.flowershop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xyh.flowershop.domain.Comment;
import com.xyh.flowershop.vo.req.comment.CommentPageReqVo;
import com.xyh.flowershop.vo.resp.comment.CommentRespPageVo;
import com.xyh.flowershop.vo.resp.comment.CommentRespVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 10728
* @description 针对表【tb_comment】的数据库操作Mapper
* @createDate 2024-05-30 20:04:43
* @Entity com.xyh.flowershop.domain.Comment
*/
public interface CommentMapper extends BaseMapper<Comment> {

    @Select("select count(1) from tb_order t1\n" +
            "inner join tb_order_item t2\n" +
            "ON t1.id = t2.order_id  \n" +
            "WHERE user_id = #{userId} and good_id = #{id} \n" +
            "and t1.order_status not in(0,7)\n")
    int checkIsBuyer(@Param("id") String id, @Param("userId") String userId);

    /**
     * 查询父评论
     * @param page
     * @param vo
     * @return
     */
    IPage<CommentRespPageVo> findCommentByPage(IPage<CommentRespPageVo> page,@Param("vo") CommentPageReqVo vo);

    List<CommentRespVo> findSubComments(List<String> parentIds);
}




